﻿using gfLibrary;
using IYAKASAPortal.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IYAKASAPortal.PrintAll
{
    public partial class PrintAJSLCMTC : System.Web.UI.Page
    {
        private UserInfo userInfo { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] != null && Session["UserName"].ToString() != "")
            {
                string userName = Session["UserName"].ToString();
                userInfo = IYAKASAPortal.Services.UserAuthority.GetUserAuthority(userName);
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }

            if (Request["UniqueKey"] != null && Request["UniqueKey"].ToString() != "")
            {
                BindReportData(Request["UniqueKey"].ToString());
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }
        }

        private void BindReportData(string strKey)
        {
            string strPath = Server.MapPath("~/rpt/CrystalReportSLCMTCAJ.rpt");

            bool bSingle = chkSingle.Checked;

            SetCRDataSource setData = new SetCRDataSource();
            AJSLCMTC.ReportSource = setData.BindSLCMTCAJ_ReportEx(strKey, strPath, bSingle);
            AJSLCMTC.DataBind();
            AJSLCMTC.RefreshReport();
        }

        protected void btnAJ_Click(object sender, EventArgs e)
        {
            if (Request["UniqueKey"] != null && Request["UniqueKey"].ToString() != "")
            {
                Response.Redirect("PrintAJ.aspx?UniqueKey=" + Request["UniqueKey"].ToString());
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }
        }

        protected void btnRG_Click(object sender, EventArgs e)
        {
            if (Request["UniqueKey"] != null && Request["UniqueKey"].ToString() != "")
            {
                Response.Redirect("PrintAJRG.aspx?UniqueKey=" + Request["UniqueKey"].ToString());
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }
        }

        protected void btnYQ_Click(object sender, EventArgs e)
        {
            if (Request["UniqueKey"] != null && Request["UniqueKey"].ToString() != "")
            {
                BindReportData(Request["UniqueKey"].ToString());
            }
        }

        protected void chkSingle_CheckedChanged(object sender, EventArgs e)
        {
            btnYQ_Click(sender, e);
        }
    }
}